//
// Created by zhupi on 2024/10/16.
//

#include "message_tree.h"
#include <QStyleFactory>

MessageTree::MessageTree(QWidget *parent)  : QDockWidget(parent)
{

}

void MessageTree::Initial() {

    treeWidget_ = new QTreeWidget(this);
    treeWidget_->setColumnCount(1);  // 设置列数
    treeWidget_->setStyle(QStyleFactory::create("windows"));
    treeWidget_->setHeaderLabel("Message Manager");  // 设置标题
    this->setWidget(treeWidget_);
    Test();
    treeWidget_->expandAll();  // 展开所有节点

}

void MessageTree::Test()
{
    QTreeWidgetItem *projectItem = new QTreeWidgetItem(treeWidget_);
    projectItem->setText(0, "Project1 (C:/Users/15663/Documents/Ansoft/)");
    projectItem->setIcon(0, QIcon(":/icons/folder.png"));  // 设置图标

    QTreeWidgetItem *hfssItem = new QTreeWidgetItem(projectItem);
    hfssItem->setText(0, "HFSSDesign1 (DrivenModal)");
    hfssItem->setIcon(0, QIcon(":/icons/file.png"));  // 设置图标

    QTreeWidgetItem *errorItem1 = new QTreeWidgetItem(hfssItem);
    errorItem1->setText(0, "Failed to read component file C:/Program Files/Ansys...");
    errorItem1->setIcon(0, QIcon(":/icons/error.png"));

    QTreeWidgetItem *errorItem2 = new QTreeWidgetItem(hfssItem);
    errorItem2->setText(0, "Failed to read component file C:/Program Files/Ansys...");
    errorItem2->setIcon(0, QIcon(":/icons/error.png"));

    QTreeWidgetItem *licenseItem = new QTreeWidgetItem(hfssItem);
    licenseItem->setText(0, "License electronics_desktop expires in 0 days. (8:44:29 上午 10月13, 2024)");

}
